<template>
  <!-- 种子线包装 -->
  <div class="item">
    <div class="header">
      <div class="tag">
        工单号：{{ detail.aggregate.woid }}
      </div>
      <div class="progress">
        <div class="progress-content">
          <span>今日产量{{ detail.aggregate.yield }}</span>
          <span>工单完成率{{ detail.aggregate.pc }}%</span>
        </div>
        <div class="bg-active" :style="{ width: detail.aggregate.pc + '%' }"></div>
      </div>
      <div class="tag">
        FTQ：{{ detail.aggregate.ftq }}%
      </div>
    </div>
    <div class="content">
      <div class="title">{{ deviceInfo.name }}</div>
      <div class="subtitle">
        <div class="spec">
          <div>型号：{{ detail.aggregate.model }}</div>
          <div>SN：{{ detail.aggregate.sn }}</div>
        </div>
        <div class="status" :class="detail.aggregate.result ? 'ok' : 'ng'">
          {{ detail.aggregate.result ? "OK" : "NG" }}
        </div>
      </div>
      <preview :config="deviceInfo" :states="detail.states" />
    </div>
    <div class="footer">
      <div class="logs">
        <div class="log-item" :class="i.result ? 'ok' : 'ng'" v-for="i in detail.logs" :key="i">
          {{ i.log }}
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import preview from './preview.vue'
export default {
  name: 'FastenerBoard',
  components: {
    preview
  },
  props: {
    deviceInfo: {
      type: Object,
      default: () => ({})
    },
    detail: {
      type: Object,
      default: () => ({})
    }
  },
  data() {
    return {
      
    }
  },
  created() {
  },
  methods: {
  }
}
</script>

<style scoped lang="less">
.item {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background-color: cadetblue;
  border-right: 1px solid #ccc;

  .header {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    padding: 10px;
    height: 60px;

    .tag {
      background-color: #108ee9;
      line-height: 40px;
      height: 40px;
      padding: 0 10px;
      border-radius: 5px;
    }

    .progress {
      background-color: #ccc;
      width: 300px;
      height: 40px;
      line-height: 40px;
      border-radius: 5px;
      overflow: hidden;
      position: relative;

      .bg-active {
        height: 40px;
        background-color: aquamarine;
        position: absolute;
        top: 0;
        left: 0;
      }

      .progress-content {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        z-index: 2;
        padding: 0 10px;
        box-sizing: border-box;

        span {
          display: inline-block;
          width: 50%;
          text-align: center;
          box-sizing: border-box;
        }
      }
    }
  }

  .ng {
    color: firebrick;
  }

  .ok {
    color: lawngreen;
  }

  .content {
    padding: 10px;
    flex: 1;
    height: 1px;
    overflow: hidden;

    .title {
      text-align: center;
      font-size: 24px;
      font-weight: bold;
    }

    .subtitle {
      display: flex;
      flex-direction: row;
      justify-content: space-between;
      font-size: 18px;
      font-weight: 600;
    }
  }

  .footer {
    height: 160px;
    background-color: #eee;
    padding: 5px;

    .logs {
      height: 100%;
      overflow: auto;
    }
  }
}
</style>